package jsyf.oa.web.report.wechatRelay;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.FastJsonConvert;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.report.wechatRelay.WechatShareFacade;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by y on 2018/4/5.
 */
@Api(value = "微信新报表接口", description = "微信新报表接口")
@Controller
@RequestMapping("/WechatShareRegion")
public class WechatShareRegionController {
    @Resource
    private WechatShareFacade wechatShareRegionFacade;
    @ResponseBody
    @RequestMapping(value = "/getWechatTotal.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "微信个人部门汇总",
            notes = "微信个人部门汇总 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:'20171216210041E5A8F7995E68215C12',dateTime:'2018-04'}", dataType = "String", paramType = "body")
    public void getWechatTotal(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject jsonObject = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        JSONObject records = this.wechatShareRegionFacade.getWechatTotal(jsonObject);
        if (records != null) {
            ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
        } else {
            ResponseUtils.putJsonResponse(response, BaseUtils.errorrRespond("获取数据错误"));
        }
    }
    @ResponseBody
    @RequestMapping(value = "/getWechatTotalforDepartByuserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "微信部门汇总ByUserId",
            notes = "微信部门汇总ByUserId ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:'201712162032474387FC7EAE66BEFF22',dateTime:'2018-04'}", dataType = "String", paramType = "body")
    public void getWechatTotalforDepartByuserId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject jsonObject = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        JSONObject records = this.wechatShareRegionFacade.getWechatTotalforDepartByuserId(jsonObject);
        if (records != null) {
            ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
        } else {
            ResponseUtils.putJsonResponse(response, BaseUtils.errorrRespond("获取数据错误"));
        }
    }
    @ResponseBody
    @RequestMapping(value = "/getForPersonalByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "查询区域经理微信转发列表",
            notes = "查询区域经理微信转发列表 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:'20171216210041E5A8F7995E68215C12',dateTime:'2018-04'}", dataType = "String", paramType = "body")
    public void getForPersonalByUserIdAndDateTime(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject jsonObject = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        List<JSONObject> records = this.wechatShareRegionFacade.getForPersonalByUserIdAndDateTime(jsonObject);
        if (records != null) {
            ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
        } else {
            ResponseUtils.putJsonResponse(response, BaseUtils.errorrRespond("获取数据错误"));
        }
    }
    @ResponseBody
    @RequestMapping(value = "/getForDepartByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取部门首页",
            notes = "获取部门首页 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:'20171216194445A89FEF5FCCA744B988',dateTime:'2018-04-08'}", dataType = "String", paramType = "body")
    public void getForDepartByUserIdAndDateTime(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject jsonObject = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        List<JSONObject> records = this.wechatShareRegionFacade.getForDepartByUserIdAndDateTime(jsonObject);
        if (records != null) {
            ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
        } else {
            ResponseUtils.putJsonResponse(response, BaseUtils.errorrRespond("获取数据错误"));
        }
    }
    @ResponseBody
    @RequestMapping(value = "/getForCompanyByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取公司首页",
            notes = "获取公司首页 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:'20171216194445A89FEF5FCCA744B988',dateTime:'2018-04-08'}", dataType = "String", paramType = "body")
    public void getForCompanyByUserIdAndDateTime(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject jsonObject = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        List<JSONObject> records = this.wechatShareRegionFacade.getForCompanyByUserIdAndDateTime(jsonObject);
        if (records != null) {
            ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
        } else {
            ResponseUtils.putJsonResponse(response, BaseUtils.errorrRespond("获取数据错误"));
        }
    }
    @ResponseBody
    @RequestMapping(value = "/getWechatTotalforCompany.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "微信公司汇总",
            notes = "微信公司汇总 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:'2017121620364A45928497FB723F1090',dateTime:'2018-04'}", dataType = "String", paramType = "body")
    public void getWechatTotalforCompany(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject jsonObject = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        JSONObject records = this.wechatShareRegionFacade.getWechatTotalforCompany(jsonObject);
        if (records != null) {
            ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
        } else {
            ResponseUtils.putJsonResponse(response, BaseUtils.errorrRespond("获取数据错误"));
        }
    }
    /*@ResponseBody
    @RequestMapping(value = "/getForDepartBydepartId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取部门首页根据BigDepartid",
            notes = "获取部门首页根据BigDepartid ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{departId:'20180110132347178A046D926F0D804B',dateTime:'2018-04-08'}", dataType = "String", paramType = "body")
    public void getForDepartBydepartId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject jsonObject = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        List<JSONObject> records = this.wechatShareRegionFacade.getForDepartBydepartId(jsonObject);
        if (records != null) {
            ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
        } else {
            ResponseUtils.putJsonResponse(response, BaseUtils.errorrRespond("获取数据错误"));
        }
    }*/
    @ResponseBody
    @RequestMapping(value = "/getForGroupByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取集团首页",
            notes = "获取集团首页 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:'2017121620364A45928497FB723F1090',dateTime:'2018-04'}", dataType = "String", paramType = "body")
    public void getForGroupByUserIdAndDateTime(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject jsonObject = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        List<JSONObject> records = this.wechatShareRegionFacade.getForGroupByUserIdAndDateTime(jsonObject);
        if (records != null) {
            ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
        } else {
            ResponseUtils.putJsonResponse(response, BaseUtils.errorrRespond("获取数据错误"));
        }
    }
    @ResponseBody
    @RequestMapping(value = "/getWechatTotalforGroup.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "微信集团汇总",
            notes = "微信集团汇总 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:'201711271733404C9DA1461F2421F828',dateTime:'2018-04'}", dataType = "String", paramType = "body")
    public void getWechatTotalforGroup(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject jsonObject = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        JSONObject records = this.wechatShareRegionFacade.getWechatTotalforGroup(jsonObject);
        if (records != null) {
            ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
        } else {
            ResponseUtils.putJsonResponse(response, BaseUtils.errorrRespond("获取数据错误"));
        }
    }
    @ResponseBody
    @RequestMapping(value = "/getForCompanyByCompanyId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取公司首页根据companyId",
            notes = "获取公司首页根据companyId ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{companyId:'2017121617474C0586950A72B2629E79',dateTime:'2018-04-08'}", dataType = "String", paramType = "body")
    public void getForCompanyByCompanyId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject jsonObject = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        List<JSONObject> records = this.wechatShareRegionFacade.getForCompanyByCompanyId(jsonObject);
        if (records != null) {
            ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
        } else {
            ResponseUtils.putJsonResponse(response, BaseUtils.errorrRespond("获取数据错误"));
        }
    }
   /* @ResponseBody
    @RequestMapping(value = "/getWechatTotalforDepart.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "微信部门汇总根据departId",
            notes = "微信部门汇总根据departId ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{departId:'20180110132347178A046D926F0D804B',dateTime:'2018-04'}", dataType = "String", paramType = "body")
    public void getWechatTotalforDepart(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject jsonObject = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        JSONObject records = this.wechatShareRegionFacade.getWechatTotalforDepart(jsonObject);
        if (records != null) {
            ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
        } else {
            ResponseUtils.putJsonResponse(response, BaseUtils.errorrRespond("获取数据错误"));
        }
    }*/
    @ResponseBody
    @RequestMapping(value = "/getForDepartBycompanyId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取部门首页根据companyId",
            notes = "获取部门首页根据companyId ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{companyId:'2017121617474C0586950A72B2629E79',dateTime:'2018-04-12'}", dataType = "String", paramType = "body")
    public void getForDepartBycompanyId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject jsonObject = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        List<JSONObject> records = this.wechatShareRegionFacade.getForDepartBycompanyId(jsonObject);
        if (records != null) {
            ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
        } else {
            ResponseUtils.putJsonResponse(response, BaseUtils.errorrRespond("获取数据错误"));
        }
    }
    @ResponseBody
    @RequestMapping(value = "/getWechatTotalforDepartByCompanyId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "微信部门汇总根据companyId",
            notes = "微信部门汇总根据companyId ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{companyId:'2017121617474C0586950A72B2629E79',dateTime:'2018-04'}", dataType = "String", paramType = "body")
    public void getWechatTotalforDepartByCompanyId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject jsonObject = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        JSONObject records = this.wechatShareRegionFacade.getWechatTotalforDepartByCompanyId(jsonObject);
        if (records != null) {
            ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
        } else {
            ResponseUtils.putJsonResponse(response, BaseUtils.errorrRespond("获取数据错误"));
        }
    }
    @ResponseBody
    @RequestMapping(value = "/getTodayWechatShareList.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "微信转发今日数据",
            notes = "微信转发今日数据 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:'20171216210041E5A8F7995E68215C12',dateTime:'2018-05-11'}", dataType = "String", paramType = "body")
    public void getTodayWechatShareList(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject jsonObject = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        List<JSONObject> records = this.wechatShareRegionFacade.getTodayWechatShare(jsonObject);
        if (records != null) {
            ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
        } else {
            ResponseUtils.putJsonResponse(response, BaseUtils.errorrRespond("获取数据错误"));
        }
    }
    @ResponseBody
    @RequestMapping(value = "/getTodayWechatContact.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "微信好友今日数据",
            notes = "微信好友今日数据 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:'20171216210041E5A8F7995E68215C12',dateTime:'2018-05-11'}", dataType = "String", paramType = "body")
    public void getTodayWechatContact(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject jsonObject = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        List<JSONObject> records = this.wechatShareRegionFacade.getTodayWechatContact(jsonObject);
        if (records != null) {
            ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
        } else {
            ResponseUtils.putJsonResponse(response, BaseUtils.errorrRespond("获取数据错误"));
        }
    }

    @ApiOperation(
            value = "",
            notes = "微信违规消息区域经理",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @RequestMapping(value = "/regionRemind.json", method = RequestMethod.POST)
    public void regionRemind(HttpServletResponse response) {
        Boolean result = this.wechatShareRegionFacade.regionRemind();
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond("true"));
    }

    @ApiOperation(
            value = "",
            notes = "微信违规消息大区经理",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @RequestMapping(value = "/bigRegionRemind.json", method = RequestMethod.POST)
    public void bigRegionRemind(HttpServletResponse response) {
        Boolean result = this.wechatShareRegionFacade.bigRegionRemind();
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond("true"));
    }

}
